//
//  GoodsListCommonCell.m
//  TerritoryShopkeeper
//
//  Created by xiaowu on 2017/11/30.
//  Copyright © 2017年 ZDQK. All rights reserved.
//

#import "GoodsListCommonCell.h"

@implementation GoodsListCommonCell

+ (CGFloat)getHeight {
    return 135;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    [self configureUI];
}

- (void)configureUI {
    self.titleLabel.font = TextPingFangFontSize(14);
    self.titleLabel.textColor = [UIColor blackTextColor];
    
    self.priceLabel.font = TextPingFangFontSize(16);
    self.priceLabel.textColor = [UIColor redF2color];
    
    self.commentCountLabel.font = TextPingFangFontSize(12);
    self.commentCountLabel.textColor = [UIColor grayTextColor];
    
    self.goodCommentLabel.font = TextPingFangFontSize(12);
    self.goodCommentLabel.textColor = [UIColor grayTextColor];
    
    self.newgoodsLabel.font = TextPingFangFontSize(10);
    self.newgoodsLabel.textColor = [UIColor green37Color];
    self.newgoodsLabel.layer.borderWidth = 1;
    self.newgoodsLabel.layer.borderColor = [UIColor green37Color].CGColor;
    self.newgoodsLabel.layer.cornerRadius = 2;
    
    self.ticketLabel.font = TextPingFangFontSize(10);
    self.ticketLabel.textColor = [UIColor whiteColor];
    self.ticketLabel.backgroundColor = [UIColor redTextColor];
    self.ticketLabel.layer.cornerRadius = 2;
    self.ticketLabel.clipsToBounds = YES;
    
    self.postageLabel.font = TextPingFangFontSize(10);
    self.postageLabel.textColor = [UIColor redF2color];
    self.postageLabel.layer.borderWidth = 1;
    self.postageLabel.layer.borderColor = [UIColor redF2color].CGColor;
    self.postageLabel.layer.cornerRadius = 2;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setValueForCellWithModel:(GoodsListModel *)model {
    
    [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:model.gimg] placeholderImage:PlaceholderImageSmall changeContentModel:UIViewContentModeScaleAspectFill];
    self.titleLabel.text = model.gname;
    
    NSString *priceStr;
    if (model.isigoods) {
        priceStr = [NSString stringWithFormat:@"%@积分", model.gprice];
    } else {
        priceStr = [NSString stringWithFormat:@"¥%@", model.gprice];
    }
    self.priceLabel.text = priceStr;
    self.newgoodsLabel.text = model.isnew ? @" 新品 " : @"" ;
    if (!model.isnew) {
        self.newgoodsRLayout.constant = 0;
    } else {
        self.newgoodsRLayout.constant = 5;
    }
    self.ticketLabel.text = model.isdiscount ? @" 券 " : @"";
    if (!model.isdiscount) {
        self.ticketRLayout.constant = 0;
    } else {
        self.ticketRLayout.constant = 5;
    }
    self.postageLabel.text = model.isfreeshipping ? @" 包邮 " : @"";
    self.commentCountLabel.text = [NSString stringWithFormat:@"%@条评论", model.evaluate];
    self.goodCommentLabel.text = [NSString stringWithFormat:@"%@%%好评", model.escore];
    
    
}

@end
